<!DOCTYPE html>
<html style="touch-action: none;">
<head>
	<style> 
    div { margin: 1px 1px;}
    div.showbox { width: 330px;} 
    div.btnmsg { display: inline-block; width: 70px; background-color:#FFFFDD;  border-style: solid; }
    div.btncnt { display: inline-block; width: 30px; background-color:#FFFFDD;  border-style: solid; }
    div.btn { display: inline-block; width: 57px;  height:35px; background-color:#DDDDDD;  text-align: center;}
    div.btncpymsg { display: inline-block; width: 80px;  height:35px;  background-color:#DDDDDD; text-align: center;}
    div.boxstu { hidden:true }
	div.boxresult {display: inline-block;  }
    input.btn { display: inline-block; width: 130px;  text-align: center;}
    .wordWrap { word-break: break-all; word-wrap:break-word; white-space:normal; }
	table{border-collapse: collapse;}
    input.a1 { font-size:8px;}
    </style>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
<div class="showbox" id="showbox"><br>
	<input class="a1" type="radio" id="cls0"  name="clsid" onclick="setclsid(this.value)" value="0" />4班 
	<input class="a1" type="radio" id="cls1"  name="clsid" onclick="setclsid(this.value)" value="1" />7班 
	<input class="a1" type="radio" id="cls2"  name="clsid" onclick="setclsid(this.value)" value="2" />11班 
	<input class="a1" type="button" onclick="showresult()" value="显1" />
	<input class="a1" type="button" onclick="showscorebox1()" value="显2" />
	<div class="btnmsg" id="msg">&ensp;</div>
	<br>	
	<input type="checkbox" id="flagboxid" value="0" />显示Boxid
	<input type="checkbox" id="flagskip" value="1" />跳过显示
	<input type="checkbox" id="flagorigrade" value="2" />原始等级
	<div class="btncnt" id="btncnt">&ensp;</div>
	<br>
	<div class="btn" id="num0" onclick="setnumber(0)" />0</div>	
	<div class="btn" id="num1" onclick="setnumber(1)" />1</div>	
	<div class="btn" id="num2" onclick="setnumber(2)" />2</div>	
	<div class="btn" id="num3" onclick="setnumber(3)" />3</div>	
	<div class="btn" id="num4" onclick="setnumber(4)" />4</div>
    <br>
	<div class="btn" id="num5" onclick="setnumber(5)" />5</div>
	<div class="btn" id="num6" onclick="setnumber(6)" />6</div>	
	<div class="btn" id="num7" onclick="setnumber(7)" />7</div>	
	<div class="btn" id="num8" onclick="setnumber(8)" />8</div>	
	<div class="btn" id="num9" onclick="setnumber(9)" />9</div>	
    <br>
	<div class="btn" id="grade0" onclick="setactivegrade(0)" />A等</div>	
	<div class="btn" id="grade1" onclick="setactivegrade(1)" />B+等</div>	
	<div class="btn" id="grade2" onclick="setactivegrade(2)" />B等</div>	
	<div class="btn" id="grade3" onclick="setactivegrade(3)" />B-等</div>	
	<div class="btn" id="grade4" onclick="setactivegrade(4)" />C等</div>
	<div class="btn" id="grade5" onclick="setactivegrade(5)" />/</div>
	<div class="btn" id="grade6" onclick="setactivegrade(6)" />╳</div>
	<div class="btn" id="grade7" onclick="setactivegrade(7)" />假</div>
	<div class="btn" id="grade10" onclick="setactivegrade(10)" />撤销</div>
	<div class="btn" id="grade11" onclick="setactivegrade(11)" />固定</div>
	<div class="btncpymsg" id="btn" onclick="collecttoclipboard()" />导入导出</div>
	<div class="btncpymsg" id="btnshowhide" onclick="showhideboxnames()" />隐藏box</div>
	<input class="btn" id="title" type="text" onchange="changetitle()" value="输入标题" />
    <form id="codeForm" autocomplete="off" hidden >	
		<input type="button" onclick="copytoboard()" value="复制文本" />
		<input type="button" onclick="importgrade()" value="导入等级" />
		<input type="button" onclick="importorigrade()" value="导入原始等级" /><br>	
		<input type="button" onclick="importscore()" value="导入成绩" /><br>		
		<input type="button" onclick="importidscore()" value="导入智学成绩" /><br>	
		<textarea  id="textareaCodea" wrap="logical" spellcheck="false" style="height: 200px; width: 300px;"></textarea>
	</form>
	<div id="boxnames"  style="font-size:16px"></div>
	<div id="operations"  style="font-size:10px"></div>	
	<div id="exportallgrade"  style="font-size:10px"></div>
    <div>说明： 1、重新载入或者刷新会丢失所有数据 <br> 2、请采用截图的方式保存数据 <br>3、导入导出等级以后待定</div>
</div>
	<div id="gradeid"  style="font-size:8.5px"></div>	
	<div id="gradescore"  style="font-size:8.5px"></div>	
</body>
<script>
//在手机中OK，在电脑中需要调整， 需要上下移动时，请选择部分内容后上下拖动
var phoneWidth = parseInt(window.screen.width);
var phoneHeight = parseInt(window.screen.height);
var phoneScale = phoneWidth/1000;
size = phoneScale
document.body.style.zoom = size;
document.body.style.cssText += '; -moz-transform: scale(' + size + ');-moz-transform-origin: 0 0; ';
document.getElementById("msg").innerHTML = String("W:"+phoneWidth+" Scl:" + size.toFixed(1) )
</script>
<script>

class student{
	constructor(numname) {
		this.stuid = numname.substr(0,2);
		this.name =  numname.substr(2);
		this.ignore = false;
		if(this.name.substr(-1) == "|"){
			this.name = this.name.slice(0,-1);
			this.ignore = true;
		}
		this.boxid = -1;
		this.grade = [];
        this.strgrade = ["A","B+","B","B-","C","/","×","假","╳"];
		this.score = ""
	}
	cleardata(){
		this.boxid = -1
		this.grade = []
	}
	clearscoredata(){
		this.score = "";
	}
	tostring(flag = "",origrade=false){
        var sgrade = []
        for(let i of this.grade)
            sgrade.push( this.strgrade[i])
		if(flag == "boxid")
			sgrade.push(this.boxid+"")
		if(origrade){
			sgrade = this.grade
		}
		if(this.grade)
			return this.stuid + this.name + " " + sgrade.join("\t")
		else
			return this.stuid + this.name
	}
	tostringbyindex(gradeindex=0){
		if(gradeindex >= 0 && gradeindex < this.grade.length){
			var sg = this.strgrade[ this.grade[gradeindex] ]
			if(sg ==  undefined)
				sg = "";
			if(this.ignore)
				sg = "/";
			return [this.stuid + this.name , sg ];
		}else if(gradeindex == -1){//输出导入的成绩
			return [this.stuid + this.name , this.score];
		}else{
		
			if(this.ignore){
				return [this.stuid + this.name , "/"];
			}else{
				return [this.stuid + this.name, ""];
			}
		}
	}
	boxtxt(boxid){
		this.boxid = boxid
		if(this.ignore){
			return  "<div class=\"boxstu\" id=\"box"+ boxid +"\" onclick=\"onclickstu('" + boxid + "')\" >" + this.tostring() + "</div>"
		}else{
			return  "<div class=\"boxstu\" id=\"box"+ boxid +"\" onclick=\"onclickstu('" + boxid + "')\" >" + this.tostring() + "</div>"
		}
	}
	boxemptytxt(boxid){
		return  "<div class=\"boxstu\"  id=\"box"+ boxid +"\" onclick=\"onclickstu('" + boxid + "')\" hidden></div>"
	}	
	addgrade(g){
        if(g==10){
			if(this.grade.length)
				this.grade.pop()				
        }else{
            this.grade.push(g)
        }
		this.valid()
	}
	removegrade( ){
		this.grade.pop()
		this.valid()
	}
	valid(){
		if( this.boxid != -1){
            console.log( this.boxid )
            document.getElementById("box" + this.boxid).hidden = false;
			document.getElementById("box" + this.boxid).innerHTML = this.tostring();
		}
	}
	removeself(){
		if( this.boxid != -1){
            console.log( "removestu:" + this.boxid )
            document.getElementById("box" + this.boxid).hidden = true;
			document.getElementById("box" + this.boxid).innerHTML = "";
			this.boxid = -1
		}
	}
	setbackground( ){
		if( this.boxid != -1){
			document.getElementById("box" + this.boxid).style.background= "#AAAAAA";	
		}
	}
	clearbackground( ){
		if( this.boxid != -1){
			document.getElementById("box" + this.boxid).style.background= "#EEEEEE";	
		}
	}
}
class schoolclass{
	constructor(clsname,vstunames) {
		this.name = clsname.replace("班","")
		this.clsid = this.name
		this.fullname = `高三（${this.name}）班生物作业`
		this.stus = []
		for(var  i = 0; i < vstunames.length; i++ ){
			var stu = new student(vstunames[i]);
			this.stus.push( stu );	
		}	
		this.boxid = 0
	}
	maxgradelength(){
		var cnt = 0;
		for(let stu of this.stus){
			if( cnt < stu.grade.length){
				cnt = stu.grade.length;
			}
		}
		return cnt;
	}
	getstubyname(name){
		for(var  i = 0; i < this.stus.length; i++ ){
			if( name == this.stus[i].name)
				return this.stus[i];
		}
		return null;
	}
	getstubyid(id){
		for(var  i = 0; i < this.stus.length; i++ ){
			if( id == this.stus[i].stuid)
				return this.stus[i]
		}
		return null
	}
	getstubyboxid(boxid){
		for(var  i = 0; i < this.stus.length; i++ ){
			if( boxid == this.stus[i].boxid)
				return this.stus[i]
		}
		return null
	}
	boxtxt(flag="empty",skip=false){
		var vstr = []
		var boxid = 0
		for(let c of this.stus){
			if(skip)
				if(c.boxid == -1)
					continue
			if(flag == "empty")
				vstr.push( c.boxemptytxt( this.stus.length - boxid -1 )  )
			else if(flag == "txt")
				vstr.push(c.tostring())
			else if(flag == "txtboxid")
				vstr.push(c.tostring("boxid"))
			else if(flag == "origrade")
				vstr.push(c.tostring("",true))
			else
				vstr.push( c.boxtxt( boxid ) )
			boxid++
		}
		return vstr
	}
	divboxtxt(flag){
		return this.boxtxt(flag).join("");
	}
    prettybox(gradeindex=0,colcnt = 10){
        var vo = [];
		var v = this.stus
		var rowcnt = 12 //定义表格行数
		if( this.name == "11")
			rowcnt = 7
		
		for(var  i=0; i<v.length; ){
			var e = i+rowcnt;
			var vi = []
            for(var k=i; k<e; k++)
                if(v.length > k ){
					var vk = v[k].tostringbyindex(gradeindex)
                    vi.push( vk )
				}else{
					vi.push(["",""])
				}
			vo.push( vi );
			i = e;
			if(v.length < e){
				break;
			}
		}
		var vr=["<div style=\"display: inline-block;\"><table border=\"1pix\">"];
		for(var ri=0; ri<rowcnt; ri++){
			var vi = ["<tr>"]
			for(var ci=0; ci<vo.length;ci++){
				var vk =  vo[ci][ri] 
				vi.push("<td>" + vk[0] + "</td><td>" + vk[1] + "</td>");
			}
			vi.push("</tr>")
			vr.push( vi.join("") )
		}
		vr.push("</table></div>")		
		return vr;
    }
	activeboxid(){
		return this.boxid++
	}
	cleardata(){
		for(let stu of this.stus){
			stu.cleardata()
		}
		this.boxid = 0
	}
	clearscoresdata(){
		for(let stu of this.stus){
			stu.clearscoredata()
		}
		this.boxid = 0
	}	
	importidscore(kh,score){
		var stu = this.getstubyid(kh);
		if(stu==null){
			console.log("不正确考号：" + kh);
			return
		}
		if(isNaN(score)){
			stu.score = "_"
		}else{
			stu.score = score
		}
	}
	importscore(item,hasbanji){
		//班级	姓名	生物
		var vs0 = item.split("\t");
		var boxid = ""		
		if(vs0.length!=3){
			console.log("不正确格式1：" + item);
			return
		}
		var clsid = vs0[0]
		var stuname = vs0[1]
		var score = vs0[2]
		if(this.clsid == clsid){
			var stu = this.getstubyname(stuname);
			if(stu==null){
				console.log("不正确stuname：" + item);
				return
			}
			if(isNaN(score)){
				stu.score = "_"
				console.log("成绩为空：" + item);
			}else{
				stu.score = score
			}
		}
	}
	importgrade(item,isori = false,hasboxid = false){
		var vs0 = item.split(" ");
		var boxid = ""		
		if(vs0.length!=2){
			console.log("不正确格式1：" + item);
			return
		}
		var idname = vs0[0];
		var stuid = idname.substr(0,2);
		var stuname = idname.substr(2);
		var stu = this.getstubyid(Number(stuid));
		if(stu==null){
			console.log("不正确stuid：" + stuid);
			return
		}
		if(stuname != stu.name){
			console.log("不正确:学生名称不匹配，" +stuname +"-"+ stu.name);
			return
		}
		//############### 有成绩才予以导入 #######
		var vs2 = vs0[1].split("\t")
		if(hasboxid){
			boxid = Number(vs2[ vs2.length -1 ])
			vs2 = vs2.slice(0,-1)
			stu.boxid = boxid
		}else
			stu.boxid = this.activeboxid()
			
		if( isori ){
			for(let vi of vs2)
				stu.grade.push(Number(vi))
		}else{			
			for(let vi of vs2){
				var index = stu.strgrade.indexOf(vi)
				stu.grade.push(index)
			}
		}
	}
}
class working{
	constructor() {
		//长期请假同学以 | 结尾
		//console.log("constructor-begin:");		
		var clsstr = [["4班","01鲍春晓|", "02蔡雨凡", "03曾杨培淇", "04陈江山", "05董静雯", "06段师节", "07樊雨欣", "08冯宇凡", "09郭婧雯", "10郭青芸", "11贺子恒", "12简仁洁|", "13姜宇琦", "14李涵韵|", "15李淇", "16李心砚", "17李欣妍", "18李严韬", "19李月如", "20李志斌", "21李祖倩|", "22刘沛霖", "23刘禹嫣", "24刘振东", "25刘子豪|", "26刘梓涵", "27骆伊婧", "28马浩为", "29齐星楠", "30秦慈安", "31却皓然", "32饶雨枫", "33申淏予", "34宋子彤", "35覃文慧", "36唐吉熠", "37童天翔", "38王敏俊", "39王屿琪", "40吴宇航", "41向天昊", "42肖俊杰", "43杨锦洪", "44杨珂若", "45杨魏怡", "46殷振翔", "47张婧语", "48张静雯", "49张明慧", "50张钰涵", "51赵晨蕊", "52赵睿泽", "53郑贝隆", "54周家宸", "55周永志", "56朱明月", "57朱信宇", "58刘傲雪", "59周丽昕"], ["7班","01毕玄熙", "02陈海北", "03陈胤祯", "04代延轩", "05丁浩民", "06段俊杰", "07范瑞兴", "08古浩然", "09韩重阳", "10胡彬杨", "11胡佳宁", "12江彭昊", "13蒋永旭", "14亢亦心", "15孔睿哲", "16李敬文", "17李忻艾", "18刘浩宇", "19刘旭航", "20刘亦畅", "21刘长杰", "22潘文峰", "23彭启松", "24彭兴康", "25司佳硕", "26宋子瑞", "27田玉洋", "28万明涛", "29王徐然", "30魏京鑫", "31吴俊豪", "32谢亦航", "33熊文林", "34熊志远", "35徐悦祺", "36许进宝", "37杨才超", "38杨俊峰", "39杨骏驿", "40叶晨宇", "41余乐洋", "42张欣智", "43赵协豪", "44赵媛媛", "45郑佳星", "46郑子婕", "47周枫程", "48周宇飞", "49朱孟哲", "50朱鹏程", "51左俊杰", "52成奕萱"], ["11班","01陈柳言", "02陈梦格", "03陈雪碧", "04邓宝仪", "05丁文豪", "06郭琪", "07胡安然", "08李福鸣", "09李明宸", "10李赵浔", "11李芷萱", "12梁宇菲", "13林宇欣", "14任永雯", "15孙成", "16王燕棂", "17王子瑄", "18尹涵可", "19张功铭", "20张伟杰", "21张逸冉", "22郑彬彬", "23朱恩琪", "24邹马翔", "25徐静怡", "26陈宇然", "27范佳婧", "28杨奇霖"]];
		this.cls = [];
		//console.log("clsstr-length:" + clsstr.length);
		//console.log(clsstr[0]);
		for(var  i = 0; i < clsstr.length; i++ ){
			var names = clsstr[i];
			this.cls.push( new schoolclass(names[0],names.slice(1,)) );			
		}
		this.dcls = {}
		for(let c of this.cls)
			this.dcls[Number(c.clsid)] = c;
		this.title = "暂无标题";
		this.clsid = -1;
		this.activegride = 0;
		this.prestudent = null;
		this.activestudent = null;
		this.colors = ["#FF0000","#dd0000","#bb0000","#990000","#770000","#550000","#440000","#330000"];
		this.n = -1;
		this.gradefixed = false
		//document.write("constructor-OK"); 会改变DOM结构
		//console.log("constructor-OK");		
	}
	activecls(){
		return this.cls[this.clsid];
	}	
	setnumid(numid){
        if(w.clsid == -1)
            return
		console.log("nownumid:" + numid)
		if(this.n == -1){
			this.n = numid
            document.getElementById("msg").innerHTML = String(numid)
		}else{
			var id = String(this.n) + String(numid)
			this.n = -1
			var stu = this.activecls().getstubyid(id)
			if(stu){
                if(stu.boxid != -1){
                    document.getElementById("msg").innerHTML = "已在"
                }else{
                    stu.boxid = this.activecls().activeboxid()
					if(w.gradefixed){
						if(stu.grade.length == 0 ){
							stu.addgrade(w.activegride);
						}
					}
                    stu.valid()
                    this.activestudent = stu
                    document.getElementById("msg").innerHTML = String(stu.stuid+stu.name)
                }
				document.getElementById("btncnt").innerHTML = stu.boxid + 1
			}else{
				document.getElementById("msg").innerHTML = "NoId" + id
			}
		}
	}
    setactivestudent(stu){
        //更改背景和显示当前名字
        if(w.activestudent)
            w.activestudent.clearbackground()
        if(stu)
            stu.setbackground()
        w.activestudent = stu
        document.getElementById("msg").innerHTML  = String(stu.stuid+stu.name)
    }
}
var w = new working();	

function setclsid(cid){
	clsid = Number(cid);
	if(w.clsid == -1){
		w.clsid = clsid
		showbox()
	}else if(w.clsid != clsid){
		var r = confirm("确认更改班级吗？")
		if(r == true ){			
			w.clsid = clsid
			showbox()
		}else{
			document.getElementById("cls"+w.clsid).checked = true
		}
	}
	//console.log("setclsid:"+w.clsid)
}
function showbox(){
	//console.log("showbox")
	document.getElementById("boxnames").innerHTML = w.activecls().divboxtxt("empty");
	for(let stu of w.activecls().stus){
		stu.valid()
	}
	document.getElementById("title").value = w.title
}
function showresult(){ //w.n 标明考试的次数
	if(w.clsid == -1)
        return   
    var element = document.getElementById("gradeid");
    element.hidden = !element.hidden;	
	if(! element.hidden) {
		var gradeindex = 0;
		var strgrade = ""
		if(w.n!=-1)
			gradeindex = w.n
		if(w.n == 9){
			strgrade = "";
			var cnts = w.activecls().maxgradelength()
			for(var i=0; i<cnts; i++){
				title = w.title+"-"+(i+1) 
				if( w.title.indexOf("-")>0){
					nstr = w.title.substring( w.title.indexOf("-")+1 )
					if(!isNaN(nstr))
						title = w.title.substring(0,w.title.indexOf("-")+1 ) + (i+Number(nstr))
				}
				strgrade += w.activecls().fullname+" 名称："+title+"<br>\n"+ w.activecls().prettybox(i).join("\n") + "<br><br>"
			}
		}else{
			title = w.title+"-1";
			if( w.title.indexOf("-")>0)
				title = w.title ;
			strgrade =  w.activecls().fullname+" 名称："+ title +"<br>\n" +  w.activecls().prettybox(gradeindex).join("\n");
		}
        document.getElementById("gradeid").innerHTML = strgrade;
		document.getElementById("title").value = w.title
    }
}
function setactivegrade(gradeid){
	g = Number(gradeid);
	if(g<10){
		document.getElementById("grade"+w.activegride).style.background = "#DDDDDD";
		document.getElementById("grade"+g).style.background = "#999999";
		w.activegride = g
	}else if(gradeid==11){
		w.gradefixed = !w.gradefixed;
		if( w.gradefixed)
			document.getElementById("grade11").style.background = "#999999";
		else 
			document.getElementById("grade11").style.background = "#DDDDDD";
		return
    }
    if(w.activestudent==null)
        return
    if(gradeid==10){
        if(w.n != -1){
            w.n = -1
            document.getElementById("msg").innerHTML = " "
        }else if(w.activestudent.grade.length == 0){
            if( w.activecls().boxid == w.activestudent.boxid + 1){			
				w.activestudent.removeself()
				w.activecls().boxid  = w.activecls().boxid - 1	
				document.getElementById("btncnt").innerHTML = w.activecls().boxid
				if(w.activecls().boxid)
					w.setactivestudent( w.activecls().getstubyboxid(w.activecls().boxid-1) )
            //删除该学生
			}
        }else{
            w.activestudent.removegrade()
        }
    }else if(w.activestudent){
		w.activestudent.addgrade(gradeid)
	}else{
		return
	}
}
function setnumber(numid ){
	console.log(numid)
	w.setnumid(numid)
}
function onclickstu(boxid){
	stu = w.activecls().getstubyboxid(boxid)
    w.setactivestudent(stu)	
}
function collecttoclipboard(){
    if(w.clsid == -1)
        return
    var element = document.getElementById("codeForm");
    element.hidden = !element.hidden;
	var isshowboxid = document.getElementById("flagboxid").checked
	var isskip = document.getElementById("flagskip").checked
	var isorigrade = document.getElementById("flagorigrade").checked
	var flag = "txt"
	
	if(! element.hidden)
		var title = document.getElementById("title").value
		var txt=""
		if(isshowboxid)
			txt = w.activecls().boxtxt("txtboxid",isskip).join("\n")
		else if(isorigrade)
			txt = w.activecls().boxtxt("origrade",isskip).join("\n")
		else
			txt = w.activecls().boxtxt("txt",isskip).join("\n")
		var boxidstr = ""
		if(isshowboxid){
			boxidstr = "|hasboxid|"
		}
		txt = "标题："+title+boxidstr+"\n" + txt;
		document.getElementById("textareaCodea").innerHTML = txt	
		document.getElementById("textareaCodea").value = txt
}		
function copytoboard() {
    //console.log("copyText....")
	copyText("textareaCodea")
}
function copyText(elementid) {
	var element = document.getElementById(elementid);
	element.select();
	element.setSelectionRange(0, element.value.length);
	document.execCommand('copy');
	//element.remove();
	alert("已复制到剪切板");
}
//复制到剪切板
// 1、取消操作  2、确认操作  显示名单时 确认操作  清空操作
function importgrade(isori = false){
	if(w.clsid == -1)
        return
    var element = document.getElementById("codeForm");   
	var isshowboxid = document.getElementById("flagboxid").checked
	var isskip = document.getElementById("flagskip").checked
	var isorigrade = document.getElementById("flagorigrade").checked
	var flag = "txt"	
	if(! element.hidden){
	//document.getElementById("textareaCodea").innerHTML= w.activecls().boxtxt("txtboxid",isskip).join("\n")
		w.activecls().cleardata();
		var hasboxid = false; //boxid位于行尾
		var s = document.getElementById("textareaCodea").value
		s = s.replace(" \t","\t").replace(" \n","\n")
		var vs = s.split("\n")
		for(var i=0; i< vs.length; i++){
			if(i==0){
				if(vs[i].substr(0,2)=="标题"){
					w.title = vs[i].substr(3)
					if(w.title.includes("|hasboxid|")){
						hasboxid = true;
						w.title = w.title.slice(0,-10);
					}
				}
			}
			var item = vs[i];
			w.activecls().importgrade(item,isori,hasboxid);
		}
		if(hasboxid)
			w.activecls().boxid = vs.length
		document.getElementById("flagboxid").checked = hasboxid
		showbox()
	}
}
function importorigrade(){
	importorigrade(true)
}
function importscore(){
	if(w.clsid == -1)
        return
    var element = document.getElementById("codeForm"); 
	var flag = "txt"	
	if(! element.hidden){	
		w.activecls().clearscoresdata();
		var hasboxid = false; //boxid位于行尾
		var s = document.getElementById("textareaCodea").value
		s = s.replace(" \t","\t").replace(" \n","\n")
		var vs = s.split("\n")
		for(var i=0; i< vs.length; i++){
			if(i==0){
				if(vs[i].substr(0,2)=="标题"){
					w.title = vs[i].substr(3)
					if(w.title.includes("|hasboxid|")){
						hasboxid = true;
						w.title = w.title.slice(0,-10);
					}
				}
			}
			var item = vs[i];
			w.activecls().importscore(item,true);
		}
		if(hasboxid)
			w.activecls().boxid = vs.length
		document.getElementById("flagboxid").checked = hasboxid
		//######### 
		showscorebox()
	}
}
function showscorebox(){
	if(w.clsid == -1)
        return   
    var element = document.getElementById("gradescore");
    element.hidden = false;	
	if(! element.hidden) {
		var strgrade = ""		
		title = w.title+"-1";
		if( w.title.indexOf("-")>0)
			title = w.title ;
		strgrade =  w.activecls().fullname+" 名称："+w.title+"-"+ 1 +"<br>\n" +  w.activecls().prettybox(-1).join("\n");		
        document.getElementById("gradeid").innerHTML = strgrade;
		document.getElementById("title").value = w.title
    }
}
function showscorebox1(){
	var element = document.getElementById("gradescore");
    element.hidden = !element.hidden;	
}
function showhideboxnames(){
	document.getElementById("boxnames").hidden = !document.getElementById("boxnames").hidden;
	if(document.getElementById("boxnames").hidden)
		document.getElementById("btnshowhide").innerHTML = "显示box"
	else
		document.getElementById("btnshowhide").innerHTML = "隐藏box"
}
function changetitle(){
	w.title = document.getElementById("title").value
}
function importidscore(){
	for(let c of w.cls) //清空所有班级
		c.clearscoresdata();
	var element = document.getElementById("codeForm"); 
	var flag = "txt"	
	if(! element.hidden){	
		w.activecls().clearscoresdata();
		var hasboxid = false; //boxid位于行尾
		var s = document.getElementById("textareaCodea").value
		s = s.replace(" \t","\t").replace(" \n","\n")
		var vs = s.split("\n")
		for(var i=0; i< vs.length; i++){			
			var item = vs[i].split("\t");
			if(item.length === 2){
				var cid = Number(item[0].slice(0,2))
				if(cid){
					var score = Number(item[1]);
					var kh = item[0].slice(2,4);
					w.dcls[cid].importidscore(kh,score);
				}else{
					console.log("Error 学号", item);
				}
			}
		}
		
		//######### 
		showscorebox()
	}
}
</script>
<script>
//禁止缩放
// 禁用浏览器ctrl +- 缩放<br>  
const keyCodeMap = {
	91: true, // command
	61: true,
	107: true, // 数字键盘 +
	109: true, // 数字键盘 -
	173: true, // 火狐 - 号
	187: true, // +
	189: true // -
}
// 覆盖ctrl||command + ‘+’/‘-’
document.onkeydown = function(event) {
	const e = event || window.event
	const ctrlKey = e.ctrlKey || e.metaKey
	if (ctrlKey && keyCodeMap[e.keyCode]) {
		e.preventDefault()
	} else if (e.detail) { // Firefox
		event.returnValue = false
	}
}
// 覆盖鼠标滑动
// 禁用鼠标滚轮缩放
document.body.addEventListener('wheel', (e) => {
	if (e.ctrlKey) {
		if (e.deltaY < 0) {
			e.preventDefault()
			return false
		}
		if (e.deltaY > 0) {
			e.preventDefault()
			return false
		}
	}
}, { passive: false })
// 禁用 浏览器工具栏 点击+- 缩放页面<br>　　

window.onload = function() {
   // 禁用双指放大
   document.addEventListener('touchstart',function (event) {
       if(event.touches.length>1){
           event.preventDefault();
       }
   });
   // 禁用双击放大
   let lastTouchEnd=0;
   document.addEventListener('touchend',function (event) {
       const now=(new Date()).getTime();
       if(now-lastTouchEnd<=300){
           event.preventDefault();
       }
       lastTouchEnd=now;
   },false);
   document.addEventListener('gesturestart', function (event) {
       event.preventDefault();
   });
}
</script>
</html>